package com.kgc.xsProvider.controller;

import com.kgc.basic.util.ResponseMsg;
import com.kgc.xs.pojo.SalesInvoice;
import com.kgc.xs.remote.SalesInvoiceRemote;
import com.kgc.xsProvider.service.SalesInvoiceService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

@RestController
public class SalesInvoiceController implements SalesInvoiceRemote {

    private Logger logger = LoggerFactory.getLogger(SalesInvoiceController.class);

    @Autowired
    private SalesInvoiceService salesInvoiceService;

    @Override
    public ResponseMsg selectSalesInvoiceByPage(Map<String, Object> map) {
        logger.info("SalesInvoiceController selectSalesInvoiceByPage map:{}", map);
        ResponseMsg msg = salesInvoiceService.selectSalesInvoiceByPage(map);
        logger.debug("SalesInvoiceController selectSalesInvoiceByPage msg:{}", msg);
        return msg;
    }

    @Override
    public ResponseMsg insertSalesInvoice(Map<String, Object> map) {
        logger.info("SalesInvoiceController insertSalesInvoice map:{}", map);
        ResponseMsg msg = salesInvoiceService.insertSalesInvoice(map);
        logger.debug("SalesInvoiceController insertSalesInvoice msg:{}", msg);
        return msg;
    }

    @Override
    public ResponseMsg selectSalesOutByCid(int customerId) {
        logger.info("SalesInvoiceController selectSalesOutByCid customerId:{}", customerId);
        ResponseMsg msg = salesInvoiceService.selectSalesOutByCid(customerId);
        logger.debug("SalesInvoiceController selectSalesOutByCid msg:{}", msg);
        return msg;
    }

    @Override
    public ResponseMsg selectSalesOutByCode(String code) {
        logger.info("SalesInvoiceController selectSalesOutByCode code:{}", code);
        ResponseMsg msg = salesInvoiceService.selectSalesOutByCode(code);
        logger.debug("SalesInvoiceController selectSalesOutByCode msg:{}", msg);
        return msg;
    }

    @Override
    public ResponseMsg deleteSalesInvoice(int id) {
        logger.info("SalesInvoiceController deleteSalesInvoice id:{}", id);
        ResponseMsg msg = salesInvoiceService.deleteSalesInvoice(id);
        logger.debug("SalesInvoiceController deleteSalesInvoice msg:{}", msg);
        return msg;
    }

    @Override
    public ResponseMsg selectSalesInvoiceByCode(String code) {
        logger.info("SalesInvoiceController selectSalesInvoiceByCode code:{}", code);
        ResponseMsg msg = salesInvoiceService.selectSalesInvoiceByCode(code);
        logger.debug("SalesInvoiceController selectSalesInvoiceByCode msg:{}", msg);
        return msg;
    }

    @Override
    public ResponseMsg selectSalesInvoiceDetailByCode(String invoiceCode) {
        logger.info("SalesInvoiceController selectSalesInvoiceDetailByCode invoiceCode:{}", invoiceCode);
        ResponseMsg msg = salesInvoiceService.selectSalesInvoiceDetailByCode(invoiceCode);
        logger.debug("SalesInvoiceController selectSalesInvoiceDetailByCode msg:{}", msg);
        return msg;
    }


    @Override
    public ResponseMsg deleteSalesInvoiceByCode(@RequestParam("code") String code) {
        logger.info("SalesInvoiceController deleteSalesInvoiceByCode code:{}", code);
        ResponseMsg msg = salesInvoiceService.deleteSalesInvoiceByCode(code);
        logger.debug("SalesInvoiceController deleteSalesInvoiceByCode msg:{}", msg);
        return msg;
    }

    @Override
    public ResponseMsg deleteSalesDetailsByCode(@RequestParam("code") String code) {
        logger.info("SalesInvoiceController deleteSalesDetailsByCode:{}", code);
        ResponseMsg msg = salesInvoiceService.deleteSalesDetailsByCode(code);
        logger.debug("SalesInvoiceController deleteSalesDetailsByCode msg:{}", msg);
        return msg;
    }

    @Override
    public ResponseMsg insertMainSalesInvoice(SalesInvoice salesInvoice) {
        return salesInvoiceService.insertMainSalesInvoice(salesInvoice);
    }

    @Override
    public ResponseMsg getOutStoreList(@RequestBody Map<String, Object> map) {
        logger.info("SalesInvoiceController getOutStoreList map:{}",map);
        ResponseMsg msg = salesInvoiceService.getOutStoreList(map);
        logger.debug("SalesInvoiceController getOutStoreList msg:{}",msg);
        return msg;
    }
}
